package com.tiantian.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @ClassName DemoController
 * @Description TODO
 * @Author tant
 * @Date 2025/2/26 13:05
 */
@RestController
@RequestMapping("/demo")
public class DemoController {

    @Value("${env.location}")
    private String location;

    @Autowired
    private RedisTemplate redisTemplate;


    @GetMapping("/location")
    public String location() {
        return "current location:" + location;
    }

    @GetMapping("/redis")
    public String redis(){
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set("name",String.valueOf(System.currentTimeMillis()));
        return Objects.requireNonNull(valueOperations.get("name")).toString();
    }
}

    